//
//  BeautyView.m
//  YouinRTCDemo
//
//  Created by 潘欣 on 2025/3/13.
//

#import "BeautyView.h"
#import <LSTPopView/LSTPopView.h>
#import <Masonry/Masonry.h>
#import "YPWButton+Style.h"
#import "RYAlertController.h"

// 定义存储键
static NSString *const kEyebrowIntensityKey = @"browStrength";
static NSString *const kEyelashIntensityKey = @"lashStrength";
static NSString *const kEyeshadowIntensityKey = @"shadowStrength";
static NSString *const kPupilIntensityKey = @"pupilStrength";
static NSString *const kBlushIntensityKey = @"blushStrength";
static NSString *const kLipstickIntensityKey = @"lipStrength";

typedef NS_ENUM(NSInteger, BeautyEffectType) {
    BeautyEffectTypeLightening, // 美白
    BeautyEffectTypeRedness,    // 红润
    BeautyEffectTypeSharpness,  // 锐利
    BeautyEffectTypesmooth,  // 平滑
};



@interface BeautyView ()
@property (nonatomic,weak) LSTPopView *popView;
@property (nonatomic, strong) UIView *bgView;//白色背景
@property (nonatomic, strong) UISlider *slider;
@property (nonatomic, strong) UIButton *beautyButton;//美颜
//@property (nonatomic, strong) UIButton *bodyButton;//美型
@property (nonatomic, strong) UIButton *makeupButton;//美妆
@property (nonatomic, strong) UIButton *reloadButton;//重置
@property (nonatomic, strong) UIButton *switchButton;//美颜开关
@property (nonatomic, strong) UIButton *makeUpswitchButton;//美妆开关
@property (nonatomic, strong) NSArray *beautyArray;//美颜数据
@property (nonatomic, strong) UILabel *verticalLine;
@property (nonatomic, strong) NSMutableArray *beautyButtonsArray;
@property (nonatomic, strong) NSMutableArray *bodyButtonsArray;
@property (nonatomic, strong) NSMutableArray *makeUpButtonsArray;
@property (nonatomic, strong) NSMutableArray *bigButtonsArray;
@property (nonatomic, strong) NSMutableArray *smallMakeBtnsArray;
@property (nonatomic, strong) NSMutableArray *bigMakeUpTitlesArray;//眉毛，睫毛等
@property (nonatomic, strong) UIView *fourthLevelContainer;
// 美颜按钮容器
@property (nonatomic, strong) UIView *beautyContainer;
// 美型按钮容器
//@property (nonatomic, strong) UIView *styleContainer;
// 美妆按钮容器
@property (nonatomic, strong) UIView *makeUpContainer;
@property (nonatomic, strong) UIView *smallMakeContainer;
@property (nonatomic, assign) BeautyEffectType currentEffectType; // 当前选中的效果类型
@property (nonatomic, assign) CGFloat lighteningLevel; // 美白强度
@property (nonatomic, assign) CGFloat rednessLevel;   // 红润强度
@property (nonatomic, assign) CGFloat sharpnessLevel; // 锐利强度
@property (nonatomic, assign) CGFloat smoothLevel; // 平滑强度

//美妆
// 共用Slider
@property (nonatomic, strong) UISlider *intensitySlider;

// 当前选中的特征类型
@property (nonatomic, assign) NSInteger currentFeatureType;

// 各特征强度值
@property (nonatomic, assign) float eyebrowIntensity;
@property (nonatomic, assign) float eyelashIntensity;
@property (nonatomic, assign) float eyeshadowIntensity;
@property (nonatomic, assign) float pupilIntensity;
@property (nonatomic, assign) float blushIntensity;
@property (nonatomic, assign) float lipstickIntensity;
//是否为第一级标题 0 是美颜，1 是美妆
@property (nonatomic, assign) int isBiggestTitle;
@end

@implementation BeautyView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.beautyButtonsArray = [NSMutableArray array];
        self.bodyButtonsArray = [NSMutableArray array];
        self.makeUpButtonsArray = [NSMutableArray array];
        self.smallMakeBtnsArray = [NSMutableArray array];
        self.bigMakeUpTitlesArray = [[NSMutableArray alloc] initWithObjects:
                                     @[@"无",@"眉毛1 ",@"眉毛2"],
                                     @[@"无",@"眼睫毛1 ",@"眼睫毛2"],
                                     @[@"无",@"眼影1 ",@"眼影2"],
//                                     @[@"无",@" 瞳孔1 ",@" 瞳孔2 "],
                                     @[@"  类型  ",@"  颜色  "],
                                     @[@"  类型  ",@"  颜色  "],
                                     nil];
        
        
        self.beautyContainer = [[UIView alloc] init];
//        self.styleContainer = [[UIView alloc] init];
        self.makeUpContainer = [[UIView alloc] init];
        self.smallMakeContainer = [[UIView alloc] init];
        
       [self.bgView addSubview:self.beautyContainer];
//       [self.bgView addSubview:self.styleContainer];
        [self.bgView addSubview:self.makeUpContainer];
        [self.makeUpContainer addSubview:self.smallMakeContainer];
        // 创建UISlider
        self.slider = [[UISlider alloc] initWithFrame:CGRectMake(50, 0, SCREEN_WIDTH-100, 30)];
        [self.slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
        // 设置slider的最小值和最大值
        self.slider.minimumValue = 0.0;
        self.slider.maximumValue = 1.0;
    
        // 设置slider的默认值为0.5
        self.slider.value = 0.5;
        // 将slider添加到视图中
        [self addSubview:self.slider];
        
        
        
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.mas_equalTo(self);
            make.height.offset(150);
        }];
        
        [self.beautyButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(self.bgView).offset(15);
        }];
        
//        [self.bodyButton mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(self.beautyButton.mas_right).offset(20);
//            make.top.mas_equalTo(self.bgView).offset(15);
//        }];
        
        [self.makeupButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.beautyButton.mas_right).offset(20);
            make.top.mas_equalTo(self.bgView).offset(15);
        }];
        
        [self.reloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.bgView).offset(-15);
            make.top.mas_equalTo(self.bgView).offset(15);
        }];
        
        [self.switchButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.bgView).offset(10);
            make.top.mas_equalTo(self.beautyButton.mas_bottom).offset(10);
            make.width.offset(60);
        }];
        
        [self.makeUpswitchButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.bgView).offset(10);
            make.top.mas_equalTo(self.beautyButton.mas_bottom).offset(10);
            make.width.offset(60);
        }];
        
        [self.verticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.switchButton.mas_right).offset(10);
            make.bottom.mas_equalTo(self.switchButton).offset(7);
            make.size.mas_equalTo(CGSizeMake(1, 45));
        }];
        
        
        self.bigButtonsArray = [NSMutableArray arrayWithObjects:self.beautyButton,self.makeupButton, nil];
        
        // 2. 设置容器约束
           [self.beautyContainer mas_makeConstraints:^(MASConstraintMaker *make) {
               make.top.mas_equalTo(self.bgView).offset(50);
               make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
               make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
               make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-10);
           }];
           
//           [self.styleContainer mas_makeConstraints:^(MASConstraintMaker *make) {
//               make.top.mas_equalTo(self.bgView).offset(50);
//               make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
//               make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
//               make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-10);
//           }];
        
        [self.makeUpContainer mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bgView).offset(50);
            make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
            make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
            make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-10);
        }];
        [self.smallMakeContainer mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(self.makeUpContainer);
            make.top.mas_equalTo(self.makeUpContainer).offset(30);
            make.height.offset(50);
        }];
   
           // 3. 默认显示美颜容器，隐藏美型容器
        self.beautyContainer.hidden = NO;
//        self.styleContainer.hidden = YES;
        self.makeUpContainer.hidden = YES;

        
        //美颜
        NSArray *beautyArr = @[@"beauty_white",@"beauty_red",@"beauty_rui",@"beauty_ping"];
        NSArray *beautyTitle = @[@"美白",@"红润",@"锐利",@"平滑"];
        UIButton *previousButton = nil;
        for (int i = 0; i < beautyArr.count; i ++) {
            UIButton *beautyButtons = [UIButton buttonWithType:UIButtonTypeCustom];
            [beautyButtons setTitle:beautyTitle[i] forState:UIControlStateNormal];
            [beautyButtons setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
            [beautyButtons setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            beautyButtons.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
            [beautyButtons setImage:[UIImage imageNamed:beautyArr[i]] forState:UIControlStateNormal];;
            beautyButtons.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [beautyButtons setButtonImageAlignmentStyle:ButtonAlignmentStyleTop imageAndLabelSpace:0];
            [beautyButtons addTarget:self action:@selector(beautyActions:) forControlEvents:UIControlEventTouchUpInside];
            beautyButtons.tag = 100+i;
            [self.beautyContainer addSubview:beautyButtons];
            
            if (i == 0) {
                beautyButtons.selected = YES;
            }
            [beautyButtons mas_makeConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(self.switchButton).offset(-2);
                if (i==0) {
                    make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
                }else{
                    // 后续按钮左对齐到前一个按钮右侧+3
                    make.left.equalTo(previousButton.mas_right).offset(3);
                }
                
                
                if (i == beautyArr.count-1) {
                    make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
                }
            }];
            // 设置所有按钮等宽
                if (previousButton) {
                    [beautyButtons mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.width.equalTo(previousButton);
                    }];
                }
                
                previousButton = beautyButtons;
            
            [self.beautyButtonsArray addObject:beautyButtons]; // 存入数组

        }
        
        ///美型
//        NSArray *bodyArr = @[@"body_smallface",@"body_shouface",@"body_longface",@"body_zhaiface",@"body_etou",@"body_egu"];
//        NSArray *bodyTitle = @[@"小脸",@"瘦脸",@"脸长",@"脸窄",@"额头",@"额骨"];
//        UIButton *bodyPreviousButton = nil;
//        for (int i = 0; i < bodyArr.count; i ++) {
//            UIButton *bodyButtons = [UIButton buttonWithType:UIButtonTypeCustom];
//            [bodyButtons setTitle:bodyTitle[i] forState:UIControlStateNormal];
//            [bodyButtons setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
//            [bodyButtons setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
//            bodyButtons.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
//            [bodyButtons setImage:[UIImage imageNamed:bodyArr[i]] forState:UIControlStateNormal];;
//            bodyButtons.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
//            [bodyButtons setButtonImageAlignmentStyle:ButtonAlignmentStyleTop imageAndLabelSpace:0];
//            [bodyButtons addTarget:self action:@selector(bodyActions:) forControlEvents:UIControlEventTouchUpInside];
//            bodyButtons.tag = 200+i;
//            [self.styleContainer addSubview:bodyButtons];
//            
//            [bodyButtons mas_makeConstraints:^(MASConstraintMaker *make) {
//                make.bottom.mas_equalTo(self.switchButton).offset(-2);
//                if (i==0) {
//                    make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
//                }else{
//                    // 后续按钮左对齐到前一个按钮右侧+3
//                    make.left.equalTo(bodyPreviousButton.mas_right).offset(3);
//                }
//                
//                
//                if (i == bodyArr.count-1) {
//                    make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
//                }
//            }];
//            // 设置所有按钮等宽
//                if (bodyPreviousButton) {
//                    [bodyButtons mas_makeConstraints:^(MASConstraintMaker *make) {
//                        make.width.equalTo(bodyPreviousButton);
//                    }];
//                }
//                
//            bodyPreviousButton = bodyButtons;
//            
//            [self.bodyButtonsArray addObject:bodyButtons]; // 存入数组
//
//        }
        
        
        /// 美妆
//        NSArray *makeUpTitle = @[@"眉毛",@"眼睫毛",@"眼影",@"瞳孔",@"腮红",@"唇彩"];
        NSArray *makeUpTitle = @[@"眉毛",@"眼睫毛",@"眼影",@"腮红",@"唇彩"];
        
        UIButton *makeUpPreviousButton = nil;
        for (int i = 0; i < makeUpTitle.count; i ++) {
            UIButton *makeUpButtons = [UIButton buttonWithType:UIButtonTypeCustom];
            [makeUpButtons setTitle:makeUpTitle[i] forState:UIControlStateNormal];
            [makeUpButtons setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
            [makeUpButtons setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            makeUpButtons.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
            makeUpButtons.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
            [makeUpButtons addTarget:self action:@selector(makeUpActions:) forControlEvents:UIControlEventTouchUpInside];
            makeUpButtons.tag = 300+i;
            [self.makeUpContainer addSubview:makeUpButtons];
            if (i == 0) {
                makeUpButtons.selected = YES;
            }
            [makeUpButtons mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(self.makeUpContainer).offset(-5);
                make.height.offset(35);
                if (i==0) {
                    make.left.mas_equalTo(self.verticalLine.mas_right).offset(10);
                }else{
                    // 后续按钮左对齐到前一个按钮右侧+3
                    make.left.equalTo(makeUpPreviousButton.mas_right).offset(3);
                }
                
                
                if (i == makeUpTitle.count-1) {
                    make.right.mas_equalTo(self.bgView.mas_right).offset(-10);
                }
            }];
            // 设置所有按钮等宽
                if (makeUpPreviousButton) {
                    [makeUpButtons mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.width.equalTo(makeUpPreviousButton);
                    }];
                }
                
            makeUpPreviousButton = makeUpButtons;
            
            [self.makeUpButtonsArray addObject:makeUpButtons]; // 存入数组

        }
        
        self.isBiggestTitle = 0;
        //眉毛
        // 6. 默认显示第一个大标题的子标题
        [self updateSubTitlesForIndex:0];
        
        
//        self.lighteningLevel = 0.5;
//        self.rednessLevel = 0.5;
//        self.sharpnessLevel = 0.5;
//        self.smoothLevel = 0.5;
        
//        self.slider.value = [self safeFloatForKey:@"BeautifyLighteningLevel" defaultValue:0.5];
              self.lighteningLevel = [self safeFloatForKey:@"BeautifyLighteningLevel" defaultValue:0.5]; // 美白强度
              self.rednessLevel = [self safeFloatForKey:@"BeautifyRednessLevel" defaultValue:0.5];   // 红润强度
              self.sharpnessLevel = [self safeFloatForKey:@"BeautifySharpnessLevel" defaultValue:0.5]; // 锐利强度
              self.smoothLevel = [self safeFloatForKey:@"BeautifySmoothnessLevel" defaultValue:0.5]; // 平滑强度
        // 默认选中美白效果
        [self switchToEffect:BeautyEffectTypeLightening];
        
        //美妆
        // 加载保存的设置
            [self loadSavedSettings];
    }
    return self;
}

- (void)loadSavedSettings {
//    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    self.eyebrowIntensity = [Tool safeFloatForKey:kEyebrowIntensityKey defaultValue:0.5];
    self.eyelashIntensity = [Tool safeFloatForKey:kEyelashIntensityKey defaultValue:0.5];
    self.eyeshadowIntensity = [Tool safeFloatForKey:kEyeshadowIntensityKey defaultValue:0.5];
    self.pupilIntensity = [Tool safeFloatForKey:kPupilIntensityKey defaultValue:0.5];
    self.blushIntensity = [Tool safeFloatForKey:kBlushIntensityKey defaultValue:0.5];
    self.lipstickIntensity = [Tool safeFloatForKey:kLipstickIntensityKey defaultValue:0.5];
    
    
    // 创建共用Slider
    self.intensitySlider = [[UISlider alloc] initWithFrame:CGRectMake(50, 0, SCREEN_WIDTH-100, 30)];
    self.intensitySlider.minimumValue = 0.0;
    self.intensitySlider.maximumValue = 1.0;
    self.intensitySlider.value = self.eyebrowIntensity;//默认显示眉毛的值
    self.intensitySlider.hidden = YES;
    [self.intensitySlider addTarget:self action:@selector(makeUpSliderValueChanged:) forControlEvents:UIControlEventValueChanged];
    [self addSubview:self.intensitySlider];
}


- (UIView *)bgView
{
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor blackColor];
        _bgView.layer.cornerRadius = 10;
        _bgView.clipsToBounds = YES;
        [self addSubview:_bgView];
    }
    return _bgView;
}

- (UIButton *)beautyButton
{
    if (!_beautyButton) {
        _beautyButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_beautyButton setTitle:@"美颜" forState:UIControlStateNormal];
        [_beautyButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
        [_beautyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        _beautyButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
        [_beautyButton addTarget:self action:@selector(beautyBigTitleActions:) forControlEvents:UIControlEventTouchUpInside];
        _beautyButton.tag = 11;
        [self.bgView addSubview:_beautyButton];
        _beautyButton.selected = YES;
    }
    return _beautyButton;
}

//- (UIButton *)bodyButton
//{
//    if (!_bodyButton) {
//        _bodyButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_bodyButton setTitle:@"美型" forState:UIControlStateNormal];
//        [_bodyButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
//        [_bodyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
//        _bodyButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
//        [_bodyButton addTarget:self action:@selector(beautyBigTitleActions:) forControlEvents:UIControlEventTouchUpInside];
//        _bodyButton.tag = 22;
//        [self.bgView addSubview:_bodyButton];
//    }
//    return _bodyButton;
//}

- (UIButton *)makeupButton
{
    if (!_makeupButton) {
        _makeupButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_makeupButton setTitle:@"美妆" forState:UIControlStateNormal];
        [_makeupButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
        [_makeupButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        [_makeupButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _makeupButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
        [_makeupButton addTarget:self action:@selector(beautyBigTitleActions:) forControlEvents:UIControlEventTouchUpInside];
        _makeupButton.tag = 22;
        [self.bgView addSubview:_makeupButton];
    }
    return _makeupButton;
}

- (UIButton *)reloadButton
{
    if (!_reloadButton) {
        _reloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_reloadButton setTitle:@"重置" forState:UIControlStateNormal];
        [_reloadButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [_reloadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        _reloadButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
        // 设置图片
        [_reloadButton setImage:[UIImage imageNamed:@"loading_filled"] forState:UIControlStateNormal];
        _reloadButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [_reloadButton setButtonImageAlignmentStyle:ButtonAlignmentStyleLeft imageAndLabelSpace:5];
        _reloadButton.tag = 44;
        [_reloadButton addTarget:self action:@selector(beautyBigTitleActions:) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:_reloadButton];
        
        BOOL isChanged = [Tool checkIfUserDefaultsChanged];
        if (isChanged) {
            NSLog(@"用户已修改过默认设置");
            _reloadButton.selected = YES;
        } else {
            NSLog(@"用户未修改设置，仍为默认值");
            _reloadButton.selected = NO;
        }
    }
    return _reloadButton;
}

- (UIButton *)switchButton
{
    if (!_switchButton) {
        _switchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_switchButton setImage:[UIImage imageNamed:@"beauty_on"] forState:UIControlStateSelected];
        [_switchButton setImage:[UIImage imageNamed:@"beauty_off"] forState:UIControlStateNormal];
        [_switchButton setTitle:@"已开启" forState:UIControlStateSelected];
        [_switchButton setTitle:@"已关闭" forState:UIControlStateNormal];
        [_switchButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        [_switchButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _switchButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        _switchButton.titleEdgeInsets = UIEdgeInsetsZero;
        [_switchButton setButtonImageAlignmentStyle:ButtonAlignmentStyleTop imageAndLabelSpace:-15];
        [_switchButton addTarget:self action:@selector(switchButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:_switchButton];
        //默认是关闭的
        _switchButton.selected = [Tool safeIntForKey:@"beautySwitchButton" defaultValue:0];
        
    }
    return _switchButton;
}

- (UIButton *)makeUpswitchButton
{
    if (!_makeUpswitchButton) {
        _makeUpswitchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_makeUpswitchButton setImage:[UIImage imageNamed:@"beauty_on"] forState:UIControlStateSelected];
        [_makeUpswitchButton setImage:[UIImage imageNamed:@"beauty_off"] forState:UIControlStateNormal];
        [_makeUpswitchButton setTitle:@"已开启" forState:UIControlStateSelected];
        [_makeUpswitchButton setTitle:@"已关闭" forState:UIControlStateNormal];
        [_makeUpswitchButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        [_makeUpswitchButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _makeUpswitchButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        _makeUpswitchButton.titleEdgeInsets = UIEdgeInsetsZero;
        [_makeUpswitchButton setButtonImageAlignmentStyle:ButtonAlignmentStyleTop imageAndLabelSpace:-15];
        [_makeUpswitchButton addTarget:self action:@selector(makeUPSwitchButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:_makeUpswitchButton];
        //默认是关闭的
        _makeUpswitchButton.selected = [Tool safeIntForKey:@"makeUpBeautySwitchButton" defaultValue:0];
        _makeUpswitchButton.hidden = YES;
    }
    return _makeUpswitchButton;
}

- (UILabel *)verticalLine
{
    if (!_verticalLine) {
        _verticalLine = [[UILabel alloc] init];
        _verticalLine.backgroundColor = [UIColor lightGrayColor];
        [self.bgView addSubview:_verticalLine];
    }
    return _verticalLine;
}

// 值改变时触发的方法
- (void)sliderValueChanged:(UISlider *)sender {
    
    CGFloat value = sender.value;

       // 更新当前选中效果的值
       switch (self.currentEffectType) {
           case BeautyEffectTypeLightening:
               self.lighteningLevel = value;
               break;
           case BeautyEffectTypeRedness:
               self.rednessLevel = value;
               break;
           case BeautyEffectTypeSharpness:
               self.sharpnessLevel = value;
               break;
           case BeautyEffectTypesmooth:
               self.smoothLevel = value;
               break;
           default:
               break;
       }

       // 调用 SDK 方法应用效果
    if ([self.delegate respondsToSelector:@selector(applyBeautyEffectsWithlightening:withRedness:withSharpness:withSmooth:)]) {
        [self.delegate applyBeautyEffectsWithlightening:self.lighteningLevel withRedness:self.rednessLevel withSharpness:self.sharpnessLevel withSmooth:self.smoothLevel];
    }
    
}

- (void)switchToEffect:(BeautyEffectType)effectType {
    self.currentEffectType = effectType;
    // 更新滑块的值
    switch (effectType) {
        case BeautyEffectTypeLightening:
            self.slider.value = self.lighteningLevel;
            break;
        case BeautyEffectTypeRedness:
            self.slider.value = self.rednessLevel;
            break;
        case BeautyEffectTypeSharpness:
            self.slider.value = self.sharpnessLevel;
            break;
        case BeautyEffectTypesmooth:
            self.slider.value = self.smoothLevel;
            break;
            
        default:
            break;
    }
}

- (void)switchButtonAction:(UIButton *)sender
{
    sender.selected = !sender.selected;
    if ([self.delegate respondsToSelector:@selector(beautySwitchDelegate:withTag:)]) {
        [self.delegate beautySwitchDelegate:sender.selected withTag:11];
    }
    self.reloadButton.selected = sender.selected;
}


#pragma mark - 美妆 开关
- (void)makeUPSwitchButtonAction:(UIButton *)sender
{
    sender.selected = !sender.selected;
    if ([self.delegate respondsToSelector:@selector(beautySwitchDelegate:withTag:)]) {
        [self.delegate beautySwitchDelegate:sender.selected withTag:22];
    }
}

- (void)beautyBigTitleActions:(UIButton *)sender
{
    for (UIButton *button in self.bigButtonsArray) {
            button.selected = (button == sender);
        }
    
    // 打印当前选中的按钮 tag
    if (sender.tag == 11) {
        self.beautyContainer.hidden = NO;
//        self.styleContainer.hidden = YES;
        self.makeUpContainer.hidden = YES;
        self.switchButton.hidden = NO;
        self.makeUpswitchButton.hidden = YES;
        self.slider.hidden = NO;
        self.intensitySlider.hidden = YES;
        self.isBiggestTitle = 0;
        self.fourthLevelContainer.hidden = YES;
        
        [self jumpViewHeight:150 makeUpBlock:0];
    }
//    else if (sender.tag == 22)
//    {
////        self.styleContainer.hidden = NO;
//        self.beautyContainer.hidden = YES;
//        self.makeUpContainer.hidden = YES;
//    }
    else if (sender.tag == 22)
    {
        self.makeUpContainer.hidden = NO;
        self.beautyContainer.hidden = YES;
//        self.styleContainer.hidden = YES;
        self.switchButton.hidden = YES;
        self.makeUpswitchButton.hidden = NO;
        self.slider.hidden = YES;
        self.intensitySlider.hidden = NO;
        self.isBiggestTitle = 1;
        self.fourthLevelContainer.hidden = NO;
//        [self updateSubTitlesForIndex:1];
        [self jumpViewHeight:200 makeUpBlock:1];
    }
    else{
            
        __weak typeof(self) weakSelf = self;
        [RYAlertController showAlertWithTitle:@"提示" message:@"确定恢复默认效果吗？" appearanceProcess:^(RYAlertController * _Nonnull alertMaker) {
            alertMaker.addActionDefaultTitle(@"取消").addActionDefaultTitle(@"确定");
        } actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, RYAlertController * _Nonnull alertSelf) {
            if (buttonIndex == 1) {
                //重置
                [Tool resetAllBeautifySettings];
                [weakSelf hideView];
                weakSelf.slider.value = 0.5;
                weakSelf.lighteningLevel = 0.5; // 美白强度
                weakSelf.rednessLevel = 0.5;   // 红润强度
                weakSelf.sharpnessLevel = 0.5; // 锐利强度
                weakSelf.smoothLevel = 0.5; // 平滑强度
                
                if ([weakSelf.delegate respondsToSelector:@selector(resetBeauty)]) {
                    [self.delegate resetBeauty];
                }
                
                if ([weakSelf.delegate respondsToSelector:@selector(applyBeautyEffectsWithlightening:withRedness:withSharpness:withSmooth:)]) {
                    [weakSelf.delegate applyBeautyEffectsWithlightening:weakSelf.lighteningLevel withRedness:weakSelf.rednessLevel withSharpness:weakSelf.sharpnessLevel withSmooth:weakSelf.smoothLevel];
                }
            }
        }];
    }
   
    [UIView animateWithDuration:0.3 animations:^{
        self.beautyContainer.alpha = self.beautyContainer.hidden ? 0 : 1;
//        self.styleContainer.alpha = self.styleContainer.hidden ? 0 : 1;
        self.makeUpContainer.alpha = self.makeUpContainer.hidden ? 0 : 1;
    }];
}



- (float)safeFloatForKey:(NSString *)key defaultValue:(float)defaultValue {
    id obj = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    return obj ? [obj floatValue] : defaultValue;
}

- (void)beautyActions:(UIButton *)sender
{
  NSInteger btnIndex = [Tool safeIntForKey:@"beautySwitchButton" defaultValue:0];
    if (btnIndex!=1) {
        [[ZXMessageCase shareInstace] showMessage:@"请开启美颜"];
        return;
    }
    self.switchButton.selected = btnIndex;
    
    for (UIButton *button in self.beautyButtonsArray) {
            button.selected = (button == sender);
        }
 
    if (sender.tag == 100) {
        [self switchToEffect:BeautyEffectTypeLightening];
    }else if (sender.tag == 101)
    {
        [self switchToEffect:BeautyEffectTypeRedness];
    }
    else if (sender.tag == 102)
    {
        [self switchToEffect:BeautyEffectTypeSharpness];
    }else if (sender.tag == 103)
    {
        [self switchToEffect:BeautyEffectTypesmooth];
    }
}

#pragma mark - 美型
- (void)bodyActions:(UIButton *)sender
{
    for (UIButton *button in self.bodyButtonsArray) {
            button.selected = (button == sender);
        }
    // 打印当前选中的按钮 tag
    NSLog(@"====%ld", (long)sender.tag);
}

#pragma mark - 美妆
- (void)makeUpActions:(UIButton *)sender
{
    for (UIButton *button in self.makeUpButtonsArray) {
            button.selected = (button == sender);
        }
    
    
    if (sender.tag != 303&&sender.tag != 304 && sender.tag !=300 && sender.tag !=301) {
        [self jumpViewHeight:150 makeUpBlock:0];
    }else{
        [self jumpViewHeight:200 makeUpBlock:1];
    }
    // 打印当前选中的按钮 tag
    [self updateSubTitlesForIndex:sender.tag -300];
}

// 更新子标题
- (void)updateSubTitlesForIndex:(NSInteger)index {
    // 1. 移除旧的子标题
    [self.smallMakeContainer.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    [self.smallMakeBtnsArray removeAllObjects];
    
    // 2. 获取当前大标题对应的子标题
    NSArray<NSString *> *subTitles = self.bigMakeUpTitlesArray[index];
    
    // 3. 创建新的子标题按钮
    UIButton *meiMaoPreviousButton = nil;
    for (int i = 0; i < subTitles.count; i ++) {
        UIButton *meiMaoButtons = [UIButton buttonWithType:UIButtonTypeCustom];
        [meiMaoButtons setTitle:subTitles[i] forState:UIControlStateNormal];
        [meiMaoButtons setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];// 未选中状态样式
        [meiMaoButtons setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
        meiMaoButtons.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        meiMaoButtons.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [meiMaoButtons addTarget:self action:@selector(meiMaoActions:) forControlEvents:UIControlEventTouchUpInside];
        meiMaoButtons.tag = 400+i;
        [self.smallMakeContainer addSubview:meiMaoButtons];
        if (i == [Tool safeIntForKey:@"browStyle" defaultValue:0]&&index==0) {
            meiMaoButtons.selected = YES;
        }else if (index==1)
        {
            if (3 == [Tool safeIntForKey:@"lashStyle" defaultValue:0] && i == 1) {
                meiMaoButtons.selected = YES;
            }else if (5 == [Tool safeIntForKey:@"lashStyle" defaultValue:0] && i == 2)
            {
                meiMaoButtons.selected = YES;
            }
            
        }else if (index==2)
        {
            if (1 == [Tool safeIntForKey:@"shadowStyle" defaultValue:0] && i == 1) {
                meiMaoButtons.selected = YES;
            }else if (6 == [Tool safeIntForKey:@"shadowStyle" defaultValue:0] && i == 2)
            {
                meiMaoButtons.selected = YES;
            }
        }
//        else if (i == [Tool safeIntForKey:@"pupilStyle" defaultValue:0]&&index==3)
//        {
//            meiMaoButtons.selected = YES;
//        }
        else if (index==3&&i==0)
        {
            meiMaoButtons.selected = YES;
        }else if (index==4&&i==0)
        {
            meiMaoButtons.selected = YES;
        }
        
        
        objc_setAssociatedObject(meiMaoButtons, @"indexKey", @(index), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        
        [meiMaoButtons mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.smallMakeContainer);
            make.height.offset(50);
            if (i==0) {
                make.left.mas_equalTo(self.smallMakeContainer);
            }else{
                // 后续按钮左对齐到前一个按钮右侧+3
                make.left.equalTo(meiMaoPreviousButton.mas_right).offset(3);
            }
        }];
        // 设置所有按钮等宽
        if (meiMaoPreviousButton) {
            [meiMaoButtons mas_makeConstraints:^(MASConstraintMaker *make) {
                make.width.equalTo(meiMaoPreviousButton);
            }];
        }
        
        meiMaoPreviousButton = meiMaoButtons;
        
        [self.smallMakeBtnsArray addObject:meiMaoButtons]; // 存入数组
        
    }
    
    // 安全移除视图的完整方案
    if (self.fourthLevelContainer && self.fourthLevelContainer.superview) {
        [self.fourthLevelContainer removeFromSuperview];
        self.fourthLevelContainer = nil;
    }
    
    // 添加第四级容器视图
   
    if (index == 3|| index == 4 || index == 0 || index == 1) {
        self.fourthLevelContainer = [[UIView alloc] init];
        
        [self.bgView addSubview:self.fourthLevelContainer];
        
        [self.fourthLevelContainer mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.smallMakeContainer.mas_bottom).offset(-5);
            make.left.right.equalTo(self.smallMakeContainer);
            make.height.mas_equalTo(50);
        }];
        
        [self currentFourIndex:index withSubTitleTag:0];
    }
    
    self.fourthLevelContainer.hidden = YES;
    if (self.isBiggestTitle == 1) {
        self.fourthLevelContainer.hidden = NO;
    }
    
    self.currentFeatureType = index;
    // 更新Slider值为对应特征的强度
        switch (index) {
            case 0: // 眉毛
                self.intensitySlider.value = self.eyebrowIntensity;
                break;
            case 1: // 眼睫毛
                self.intensitySlider.value = self.eyelashIntensity;
                break;
            case 2: // 眼影
                self.intensitySlider.value = self.eyeshadowIntensity;
                break;
//            case 3: // 瞳孔
//                self.intensitySlider.value = self.pupilIntensity;
//                break;
            case 3: // 腮红
                self.intensitySlider.value = self.blushIntensity;
                break;
            case 4: // 唇彩
                self.intensitySlider.value = self.lipstickIntensity;
                break;
        }
}

#pragma mark - 美妆子标题
- (void)meiMaoActions:(UIButton *)sender
{
    
   NSInteger switchBOOL = [Tool safeIntForKey:@"makeUpBeautySwitchButton" defaultValue:0];
    if (switchBOOL) {
        // 获取当前大标题的索引
        NSNumber *indexNumber = objc_getAssociatedObject(sender, @"indexKey");
        NSInteger currentBigTitleIndex = [indexNumber integerValue]+300;// 你需要实现这个方法
            
            
        // 获取当前点击的子标题的 tag
        NSInteger subTitleTag = sender.tag;
               
        // 更新按钮的选中状态
        for (UIButton *button in self.smallMakeBtnsArray) {
            button.selected = (button == sender);
        }
        
        [self currentFourIndex:currentBigTitleIndex-300 withSubTitleTag:subTitleTag-400];
        
//        if (currentBigTitleIndex!=304&&currentBigTitleIndex != 305) {
        if (currentBigTitleIndex!=303&&currentBigTitleIndex != 304) {
            
            // 打印当前大标题索引和子标题 tag
            if ([self.delegate respondsToSelector:@selector(makeUpButtonCurrentBigTitleIndex:withSubtitle:)]) {
                [self.delegate makeUpButtonCurrentBigTitleIndex:currentBigTitleIndex withSubtitle:subTitleTag];
            }
        }
        
    }else{
        [[ZXMessageCase shareInstace] showMessage:@"请开启美妆"];
    }
    
}

//美妆 - slider 强度
- (void)makeUpSliderValueChanged:(UISlider *)sender
{
    // 根据当前选中的特征类型更新对应的强度值
        switch (self.currentFeatureType) {
            case 0: // 眉毛
                self.eyebrowIntensity = sender.value;
                break;
            case 1: // 眼睫毛
                self.eyelashIntensity = sender.value;
                break;
            case 2: // 眼影
                self.eyeshadowIntensity = sender.value;
                break;
//            case 3: // 瞳孔
//                self.pupilIntensity = sender.value;
//                break;
            case 3: // 腮红
                self.blushIntensity = sender.value;
                break;
            case 4: // 唇彩
                self.lipstickIntensity = sender.value;
                break;
        }
        
    if ([self.delegate respondsToSelector:@selector(makeUpSliders:withTag:)]) {
        [self.delegate makeUpSliders:sender.value withTag:self.currentFeatureType];
    }
    
        [self saveCurrentSettings];
}

- (void)saveCurrentSettings {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setFloat:self.eyebrowIntensity forKey:kEyebrowIntensityKey];
    [defaults setFloat:self.eyelashIntensity forKey:kEyelashIntensityKey];
    [defaults setFloat:self.eyeshadowIntensity forKey:kEyeshadowIntensityKey];
    [defaults setFloat:self.pupilIntensity forKey:kPupilIntensityKey];
    [defaults setFloat:self.blushIntensity forKey:kBlushIntensityKey];
    [defaults setFloat:self.lipstickIntensity forKey:kLipstickIntensityKey];
    
    [defaults synchronize];
}


- (void)currentFourIndex:(NSInteger)currentBigTitleIndex withSubTitleTag:(NSInteger)subTitleTag
{
    
    //            没有第四级标题时隐藏容器
            self.fourthLevelContainer.hidden = YES;
    // 检查是否有第四级标题
     if (currentBigTitleIndex==3 ||currentBigTitleIndex==4 || currentBigTitleIndex == 0 || currentBigTitleIndex == 1) {
        // 显示第四级容器
        self.fourthLevelContainer.hidden = NO;
        
        // 移除旧的第四级按钮
        [self.fourthLevelContainer.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
         
         NSArray *fourthLevelTitles = [NSArray new];
         if (currentBigTitleIndex == 0) {
             
             subTitleTag = 555;
             fourthLevelTitles = @[@" 无 ",@" 黑色 ",@" 棕色 "];
         }else if (currentBigTitleIndex ==1)
         {
             subTitleTag = 666;
             fourthLevelTitles = @[@" 无 ",@" 黑色 ",@" 棕色 "];
         }
        else if (currentBigTitleIndex==3 ) {
             
             if (subTitleTag == 0) {
                 subTitleTag = 111;
                 fourthLevelTitles = @[@"无",@"腮红1",@"腮红2"];
             }else{
                 subTitleTag = 222;
                 fourthLevelTitles = @[@"无",@"1号色",@"2号色",@"3号色",@"4号色",@"5号色"];
             }
         }else{
             
             if (subTitleTag == 0) {
                 subTitleTag = 333;
                 fourthLevelTitles = @[@"无",@"唇彩1",@"唇彩2"];
             }else{
                 subTitleTag = 444;
                 fourthLevelTitles = @[@"无",@"1号色",@"2号色",@"3号色",@"4号色",@"5号色"];
             }
         }
         
        // 创建第四级按钮
        UIButton *previousFourthButton = nil;
        for (int i = 0; i < fourthLevelTitles.count; i++) {
            UIButton *fourthButton = [UIButton buttonWithType:UIButtonTypeCustom];
            [fourthButton setTitle:fourthLevelTitles[i] forState:UIControlStateNormal];
            [fourthButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
            [fourthButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
            fourthButton.titleLabel.font = [UIFont systemFontOfSize:14];
            fourthButton.tag = 500 + i;
            [fourthButton addTarget:self action:@selector(fourthLevelAction:) forControlEvents:UIControlEventTouchUpInside];
            [self.fourthLevelContainer addSubview:fourthButton];
            
            if (currentBigTitleIndex == 3) {
                if (i == [Tool safeIntForKey:@"blushStyle" defaultValue:0]&&subTitleTag==111)
               {
                   fourthButton.selected = YES;
               }else if (i == [Tool safeIntForKey:@"blushColor" defaultValue:0]&&subTitleTag==222){
                   fourthButton.selected = YES;
               }
            }else if (currentBigTitleIndex == 4)
            {
                if (i == [Tool safeIntForKey:@"lipStyle" defaultValue:0]&&subTitleTag==333)
               {
                   fourthButton.selected = YES;
               }else if (i == [Tool safeIntForKey:@"lipColor" defaultValue:0]&&subTitleTag==444){
                   fourthButton.selected = YES;
               }
            }else if (currentBigTitleIndex == 0)
            {
                if (i == [Tool safeIntForKey:@"browColor" defaultValue:0]&&subTitleTag==555)
               {
                   fourthButton.selected = YES;
               }
            }else if (currentBigTitleIndex == 1)
            {
                 if (i == [Tool safeIntForKey:@"lashColor" defaultValue:0]&&subTitleTag==666){
                    fourthButton.selected = YES;
                }
            }
            
//
            objc_setAssociatedObject(fourthButton, @"indexFourKey", @(subTitleTag), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
            
            
            [fourthButton mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.equalTo(self.fourthLevelContainer);
                if (i == 0) {
                    make.left.equalTo(self.fourthLevelContainer);
                } else {
                    make.left.equalTo(previousFourthButton.mas_right).offset(5);
                }
                if (previousFourthButton) {
                    make.width.equalTo(previousFourthButton);
                }
            }];
            
            previousFourthButton = fourthButton;
        }
    }
}

#pragma mark - 第四级标题点击事件
- (void)fourthLevelAction:(UIButton *)sender {
    
    NSInteger switchBOOL = [Tool safeIntForKey:@"makeUpBeautySwitchButton" defaultValue:0];
    if (switchBOOL!=1) {
        [[ZXMessageCase shareInstace] showMessage:@"请开启美妆"];
        return;
    }
    
    
    // 获取当前大标题的索引
    NSNumber *indexNumber = objc_getAssociatedObject(sender, @"indexFourKey");
    NSInteger currentBigTitleIndex = [indexNumber integerValue];
    // 更新第四级按钮的选中状态
    for (UIView *view in self.fourthLevelContainer.subviews) {
        if ([view isKindOfClass:[UIButton class]]) {
            UIButton *button = (UIButton *)view;
            button.selected = (button == sender);
        }
    }
    
    // 这里可以处理第四级标题的选择逻辑
    if ([self.delegate respondsToSelector:@selector(makeUpFourTitleIndex:withSubtitle:)]) {
        [self.delegate makeUpFourTitleIndex:currentBigTitleIndex withSubtitle:sender.tag-500];
    }
}

- (void)jumpViewHeight:(CGFloat)height makeUpBlock:(BOOL)isBlock
{
    [UIView animateWithDuration:0.3 animations:^{
        [self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.mas_equalTo(self);
            make.height.offset(height);
        }];
    }];
    
    if (self.makeUpHeightBlock) {
        self.makeUpHeightBlock(isBlock);
    }
}

-(void)showView
{
    LSTPopView *popView = [LSTPopView initWithCustomView:self
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];

    popView.hemStyle = LSTHemStyleBottom;
    popView.backgroundColor = [UIColor clearColor];
    LSTPopViewWK(popView)
    popView.bgAlpha = 0.0;
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    popView.rectCorners = UIRectCornerTopLeft | UIRectCornerTopRight;
    popView.cornerRadius = 10;
    popView.sweepStyle = LSTSweepStyleY_Positive;
    popView.dragStyle = LSTDragStyleY_Positive;
    popView.sweepDismissStyle = LSTSweepDismissStyleSmooth;
    popView.bgClickBlock = ^{
        NSLog(@"点击了背景");
        [wk_popView dismiss];
    };
    self.popView = popView;

    [popView pop];
}

-(void)hideView;
{
    [self.popView dismiss];
}
-(void)dealloc
{
    NSLog(@"dealloc");
}
@end
